package com.demo2do.fms.admin.entity.search.supplier;

import com.demo2do.core.persistence.support.QueryBuilder;
import com.demo2do.core.persistence.support.QueryFilter;
import com.demo2do.core.persistence.support.QueryOrder;

import java.util.List;
import java.util.Map;

/**
 * 查询司机信息所用条件
 * Created by zhonghui on 2017/6/14.
 */
public class EmployeeSearch implements QueryBuilder {

    /**
     * 所选公司
     */
    private List<Long> orgIds;

    /**
     * 姓名
     */
    private String name;

    /**
     * 职务Id
     */
    private Long dutyId;

    /**
     * 工号
     */
    private String code;

    /**
     * 身份证
     */
    private String citizenCode;

    /**
     * 车辆信息
     */
    private String vehicle;

    /**
     * 车辆ID
     */
    private Long vehicleId;

    /**
     * 手机号
     */
    private String mp;

    /**
     *
     */
    private boolean disabled;

    private QueryOrder queryOrder;

    private QueryFilter queryFilter;

    /**
     * Instantiates a new Employee search.
     */
    public EmployeeSearch() {
        queryOrder = new QueryOrder();
    }

    /*
     * (non-Javadoc)
	 * @see com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(boolean)
	 */
    public QueryFilter getPreparedFilter(boolean refresh) {

        if (queryFilter == null || refresh) {

            queryFilter = new QueryFilter().addSentence("organization.id IN (:orgIds)", "orgIds", orgIds)
                    .addEquals("name", name)
                    .addEquals("dutyId", dutyId)
                    .addEquals("code", code)
                    .addEquals("citizenCode", citizenCode)
                    .addEquals("vehicleId", vehicleId)
                    .addEquals("mp", mp)
                    .addEquals("disabled", disabled);
        }
        return queryFilter;
    }

    /*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#getOrder()
     */
    public QueryOrder getOrder() {
        return queryOrder;
    }


    /*
     * (non-Javadoc)
	 * @see com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
	 */
    public String buildSentenceTemplate() {

        String sentence = " FROM Employee " + getPreparedFilter(false).whereSentence() + queryOrder.sentence();

        return sentence;
    }

    /*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
    public Map<String, Object> buildParameters() {
        return getPreparedFilter(false).parameters();
    }
    
    public QueryFilter getQueryFilter(){
        return getPreparedFilter(false);
    }

    /**
     * @return the orgIds
     */
    public List<Long> getOrgIds() {
        return orgIds;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the dutyId
     */
    public Long getDutyId() {
        return dutyId;
    }

    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @return the citizenCode
     */
    public String getCitizenCode() {
        return citizenCode;
    }

    /**
     * @return the vehicle
     */
    public String getVehicle() {
        return vehicle;
    }

    /**
     * @return the vehicleId
     */
    public Long getVehicleId() {
        return vehicleId;
    }

    /**
     * @return the mp
     */
    public String getMp() {
        return mp;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param orgIds the orgIds to set
     */
    public void setOrgIds(List<Long> orgIds) {
        this.orgIds = orgIds;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param dutyId the dutyId to set
     */
    public void setDutyId(Long dutyId) {
        this.dutyId = dutyId;
    }

    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @param citizenCode the citizenCode to set
     */
    public void setCitizenCode(String citizenCode) {
        this.citizenCode = citizenCode;
    }

    /**
     * @param vehicle the vehicle to set
     */
    public void setVehicle(String vehicle) {
        this.vehicle = vehicle;
    }

    /**
     * @param vehicleId the vehicleId to set
     */
    public void setVehicleId(Long vehicleId) {
        this.vehicleId = vehicleId;
    }

    /**
     * @param mp the mp to set
     */
    public void setMp(String mp) {
        this.mp = mp;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
}
